<?php
defined('_JEXEC') or die('Restricted access');
include(JPATH_COMPONENT . '/helpers.php');
$app = JFactory::getApplication();
$input = $app->input;
$itemid = $input->get('Itemid');

$item  = $input->getArray();

$vName = $input->get('view');
?>
<div class="res-title-rg">
    <span class="fl pos-icon text-c"><i class="audience"></i></span>
    <div class="title-info">
        <h2 class="fontsize20">Event Frequency</h2>
        <p><a href="#">Home</a>&nbsp;/&nbsp;Audience&nbsp;/&nbsp;Event Frequency</p>
    </div>
</div>
<div class="ws-content pdall15">
<?php if ($item['yAxis']): ?>
    <div id="main" style="height:520px;"></div>
<?php else: ?>
 	<p class="ws-tips">No report data found.</p>
<?php endif; ?>
</div>
<script type="text/javascript">

	var chart = echarts.init(document.getElementById('main'));
	option = {
		tooltip : {
			trigger: 'axis',
			axisPointer : {
				type : 'shadow'
			}
		},
		legend: {
			<?php
			$seriesarrkey = array_keys($item['seriesarr']);
			?>
			data: <?php echo json_encode($seriesarrkey)?>
		},
		grid: {
			left: '3%',
			right: '4%',
			bottom: '3%',
			containLabel: true
		},
		xAxis:  {
			type: 'value'
		},
		yAxis: {
			type: 'category',
			data: <?php echo json_encode($item['yAxis'])?>
		},
		series: [
			<?php
			$j = 0;
			foreach($item['seriesarr'] as $key => $value):
			$j++;
			?>
			{
				name: '<?php echo $key;?>',
				type: 'bar',
				stack: '总量',
				label: {
					normal: {
						show: false,
						position: 'insideRight'
					}
				},
				data: <?php echo json_encode($value)?>
			}
			<?php if ($j  < count($item['seriesarr'])){ echo ',';}

			?>

			<?php endforeach;?>
		]
	};
	chart.setOption(option);
</script>
